<template>
  <div class="bindConfirm">
    <van-nav-bar title="绑定银行卡" left-arrow @click-left="onClickLeft">
      <template #left>
        <van-icon name="arrow-left" style="color: #000; font-size: 24px" />
      </template>
    </van-nav-bar>
    <div class="bindConfirm_container">
      <div class="bindConfirm_box">
        <img
          :src="datasrc ? datasrc : '../../assets/images/image/hdpi/bank_card_front.png'"
          alt=""
          class="backgroundUrl"
        />
        <img
          src="../../assets/images/icon/common resource/hdpi/common_icon_close_n.png"
          alt=""
          class="closeIcon"
        />
      </div>
      <div class="identity_box">
        <div class="identity_item">
          <div class="name_box">
            <div>真实姓名</div>
            <div class="name">王麻子</div>
          </div>
          <div class="bank_box">
            <div>到账银行</div>
            <div class="bank">{{ bank.bankName }}</div>
          </div>
          <div class="account_box">
            <div>银行账号</div>
            <div class="account">{{ bank.bankCardNumber }}</div>
          </div>
        </div>
      </div>
      <button class="btn" @click="btnto">确认绑定</button>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { getbindUserBankCard } from '../../api/search'
import { useRouter } from 'vue-router'


    const datasrc = ref(JSON.parse(localStorage.getItem('dataSrc') as string))
    const bank:any= ref([])
    const router = useRouter()

    const userId =ref(parseInt(localStorage.getItem('userId') as string)) 
    const sessionId =ref(JSON.parse(localStorage.getItem('sessionId') as string)) 

    const onClickLeft = () => {
      history.back()
    }
    const btnto = async () => {
      console.log("userId",userId.value);
      console.log("sessionId",sessionId.value);
      const data = {
        bankCardNumber: '1234546789987654321',
        bankName: '北京银行',
        bankCardType: 1
      }
      try{
        const res=await getbindUserBankCard(userId.value,sessionId.value ,data)
        console.log(res);
        console.log(1111);
        router.push("/checkInformation")
      }catch(error){
        console.log(error);
      }
    }
</script>
<style>
 @import './checkBank.scss'
</style>